<template>
  <div>
    <div style="height:750px">
      <el-table :data="contents">
        <el-table-column label="问题标题">
          <template slot-scope="scope">
            <span style="margin-left: 10px">{{ scope.row.title }}</span>
          </template>
        </el-table-column>

        <el-table-column label="问题描述" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <span style="margin-left: 10px">{{ scope.row.problemDescription }}</span>
          </template>
        </el-table-column>

        <el-table-column label="电话">
          <template slot-scope="scope">
            <span style="margin-left: 10px">{{ scope.row.phone }}</span>
          </template>
        </el-table-column>

        <el-table-column label="地址">
          <template slot-scope="scope">
            <span style="margin-left: 10px">{{ scope.row.addr }}</span>
          </template>
        </el-table-column>

        <el-table-column label="操作" width="170" style="text-align:center">
          <template slot-scope="scope">
             <el-tooltip class="item" effect="dark" content="撤回投诉问题" placement="top-start">
            <el-button
              type="primary"
              icon="el-icon-circle-close"
              size="mini"
              circle
              @click="deleteproblem(scope.row)"
            ></el-button>
             </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      contents: [],
      username: this.$store.state.user.username,
    };
  },
  mounted() {
    this.showtable();
  },
  methods: {
    showtable() {
      this.$axios({
        method: "post",
        params: {
          userName: this.username,
        },
        url: "/older/checkAllproblems",
      })
        .then((res) => {
          console.log(res);
          this.contents = res.data.result;
        })
        .catch((error) => {
          console.log(error);
        });
    },

    deleteproblem(row) {
      if (confirm("确定要撤回您上诉的问题吗")) {
        this.$axios({
          method: "post",
          params: {
            id: row.id,
          },
          url: "/older/deleteProblems",
        })
          .then((res) => {
            if (res.data.code == 200) {
              this.$message.success("您已撤回上诉问题");
              this.showtable();
            }
          })
          .catch((error) => {
            console.log(error);
          });
      }
    },
  },
};
</script>

<style>
</style>